﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using XiaFControl.Controls;
using XiaFControl.Demo.Common;

namespace XiaFControl.Demo.ViewModels
{
    public class MessageBoxViewModel : ObservableObject
    {
        private RelayCommand<object> messageBoxShow;
        public RelayCommand<object> MessageBoxShow => messageBoxShow ?? (messageBoxShow = new RelayCommand<object>(MessageBoxShowExecute));
        private void MessageBoxShowExecute(object obj)
        {
            switch (obj.ToString())
            {
                case "1":
                    MessageBox.Show("有消息消息消息消息消息", "标题名称");
                    break;
                case "2":
                    var result = MessageBox.Confirm("是否删除改数据?", "提示");
                    Message.Show(Global.MessageContainerKey, $"返回结果为 {result}");
                    break;
                case "3":
                    MessageBox.Info("消息消息消息消息消息消息", "标题名称", System.Windows.MessageBoxButton.YesNo);
                    break;
                case "4":
                    MessageBox.Waring("警告警告警告警告警告警告", "标题名称", System.Windows.MessageBoxButton.YesNo);
                    break;
                case "5":
                    MessageBox.Success("成功成功成功成功成功成功", "标题名称", System.Windows.MessageBoxButton.OK);
                    break;
                case "6":
                    MessageBox.Error("错误错误错误错误错误错误", "标题名称", System.Windows.MessageBoxButton.YesNoCancel);
                    break;
            }
        }

        private RelayCommand<object> messageBoxShowContainer;
        public RelayCommand<object> MessageBoxShowContainer => messageBoxShowContainer ?? (messageBoxShowContainer = new RelayCommand<object>(MessageBoxShowContainerExecute));

        private async void MessageBoxShowContainerExecute(object obj)
        {
            switch (obj.ToString())
            {
                case "1":
                    await MessageBox.ShowInContainer(Global.MessageBoxContainerKey, "有消息消息消息消息消息");
                    break;
                case "2":
                    var result = await MessageBox.ConfirmInContainer(Global.MessageBoxContainerKey, "是否删除改数据?", "提示");
                    Message.Show("MessageContainer", $"返回结果为 {result}");
                    break;
                case "3":
                    await MessageBox.InfoInContainer(Global.MessageBoxContainerKey, "消息消息消息消息消息消息", "标题名称", System.Windows.MessageBoxButton.YesNo);
                    break;
                case "4":
                    await MessageBox.WaringInContainer(Global.MessageBoxContainerKey, "警告警告警告警告警告警告", "标题名称", System.Windows.MessageBoxButton.YesNo);
                    break;
                case "5":
                    await MessageBox.SuccessInContainer(Global.MessageBoxContainerKey, "成功成功成功成功成功成功", "标题名称", System.Windows.MessageBoxButton.OK);
                    break;
                case "6":
                    await MessageBox.ErrorInContainer(Global.MessageBoxContainerKey, "错误错误错误错误错误错误", "标题名称", System.Windows.MessageBoxButton.YesNoCancel);
                    break;
                default:
                    break;
            }
        }
    }
}
